package pw.archipelag.loaderGame.panel.scores {
	import flash.display.Sprite;
	import base.types.ArrayExt;
	import flash.events.Event;
	import pw.archipelag.loaderGame.interfaceGame.skinsPanel.SkinScores;
	
	public class ScrollScores extends Sprite {
		
		static internal var COUNT_ITEMS_VISIBLE: uint;
		private var arrObjResult: ArrayExt;
		protected var scrollArea: ScrollAreaScores;
		protected var scrollBar: ScrollBarScores;
		
		public function ScrollScores(arrObjResult: ArrayExt): void {
			this.arrObjResult = arrObjResult;
			this.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);
		}
		
		protected function onAddedToStage(e: Event): void {
			this.removeEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);
			this.scrollArea = new ScrollAreaScores(this.arrObjResult);
			this.addChild(this.scrollArea);
			this.scrollBar = new ScrollBarScores(this.scrollArea);
			this.addChild(this.scrollBar);
		}
		
		public function draw(skinScores: SkinScores): void {
			this.scrollArea.draw(skinScores);
			this.scrollBar.draw(skinScores);
		}
		
		override public function get width(): Number {
			return this.scrollBar.x + this.scrollBar.width;
		}
		
		override public function set width(value: Number): void {
			this.scrollBar.x = value - this.scrollBar.width;
			this.scrollArea.width = this.scrollBar.x - this.scrollArea.x;
		}
		
		override public function get height(): Number {
			return this.scrollBar.height;
		}
		
		override public function set height(value: Number): void {
			this.scrollBar.height = value;
		}
		
		public function destroy(): void {
			this.scrollBar.removeBarEvents();
			this.scrollBar.removeScrollAreaEvents();
			this.removeChild(this.scrollBar);
			this.scrollBar = null;
			this.scrollArea.destroy();
			this.removeChild(this.scrollArea);
			this.scrollArea = null;
		}
		
	}
	
}